package model.backoffice

trait StringConverter[A] {
  def convert(input: String): A
}

object StringConverter {
  def apply[A](implicit converter: StringConverter[A]): StringConverter[A] = converter

  given StringConverter[Int] with
    def convert(input: String): Int = input.toInt

  given StringConverter[Double] with
    def convert(input: String): Double = input.toDouble

  given StringConverter[Boolean] with
    def convert(input: String): Boolean = input.toBoolean

  given StringConverter[String] with
    def convert(input: String): String = input

  given StringConverter[Long] with
    def convert(input: String): Long = input.toLong
}
